/*
 * GbtMediaFeature.h
 *
 *  Created on: 2018年6月2日
 *      Author: zhengboyuan
 */

#ifndef GBTMEDIAFEATURE_H_
#define GBTMEDIAFEATURE_H_

#include "GbtType.h"


#ifdef __cplusplus
extern "C" {
#endif
///////////////////////////////////////////////////////////////////



/**
 * SDP 中 f= 行
 * f= v/编码格式/分辨率/帧率/码率类型/码率大小a/编码格式/码率大小/采样率
 */
typedef struct GBT_MediaFeature
{
    int videoCodec;
    int resolution;
    int fps;
    int bitrateMode;
    int bitrate;        /// kbps

    int audioCodec;
    int audioBitrate;
    int sampleRate;

} GBT_MediaFeature;


#define GBT_MEDIA_FEATURE_SEPERATOR '/'
#define GBT_MEDIA_FEATURE_VIDEO     'v'
#define GBT_MEDIA_FEATURE_AUDIO     'a'
#define GBT_MEDIA_FEATURE_SPACE     ' '

DLLEXPORT size_t gbtFeatureToString(const GBT_MediaFeature* feature, char* str, size_t size);

DLLEXPORT BOOL gbtFeatureParse(GBT_MediaFeature* feature, const char* str, size_t size);

DLLEXPORT void gbtFeatureInit(GBT_MediaFeature* feature);

DLLEXPORT BOOL gbtFeatureGetResolution(int resolution, int* width, int* height);
DLLEXPORT int gbtFeatureToResolution(int width, int height);

DLLEXPORT BOOL gbtFeatureGetSampleRate(int enumRate, int* freq);
DLLEXPORT int gbtFeatureToSampleRate(int freq);

DLLEXPORT size_t gbtFeatureAudioToString(char* str, size_t size, int codec, int bps, int freq);

DLLEXPORT GBT_AudioBitrate gbtFeatureGuessAudioBitrate(int codec);

DLLEXPORT GBT_AudioBitrate gbtFeatureGetAudioBitrate(int bps);
DLLEXPORT int gbtFeatureToAudioBitrate(GBT_AudioBitrate bitrate);

///////////////////////////////////////////////////////////////////
#ifdef __cplusplus
}
#endif


#endif /* GBTMEDIAFEATURE_H_ */
